package ru.acme.lab11.domain.client;

import ru.acme.lab11.domain.account.IAccount;
import ru.acme.lab11.domain.account.ImmutableAccount;

public class Client implements ImmutableClient {

	private String name;
	private Gender gender;
	private IAccount account;
	
	public Client(String name, Gender gender, IAccount account) {
		this.name = name;
		this.gender = gender;
		this.account = account;
	}

	public ImmutableAccount getImmutableAccount() {
		return account;
	}

	public IAccount getAccount() {
		return account;
	}

	public void setAccount(IAccount account) {
		this.account = account;
	}

	public String getName() {
		return name;
	}

	public Gender getGender() {
		return gender;
	}
	
	public void setName(String name) {
		this.name = name;
	}

	public void setGender(Gender gender) {
		this.gender = gender;
	}

	public String getClientSalutation() {
		return gender.getSalutation() + " " + name;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((gender == null) ? 0 : gender.hashCode());
		result = prime * result + ((name == null) ? 0 : name.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Client other = (Client) obj;
		if (gender != other.gender)
			return false;
		if (name == null) {
			if (other.name != null)
				return false;
		} else if (!name.equals(other.name))
			return false;
		return true;
	}

}
